/**
 * 获取URL参数
 * @param url 要解析的URL，默认为当前页面的URL
 * @param name 参数名
 * @returns 参数值
 */
export function GetQueryString(url: string, name: string) {
    try {
        const baseURL = window.location.href;
        const parsedURL = new URL(url, baseURL);
        const searchParams = parsedURL.searchParams;

        if (name.endsWith('[]')) {
            const values = searchParams.getAll(name);
            return values.map(v => decodeURIComponent(v));
        }

        const decodedValue = searchParams.get(name);
        return decodedValue ? decodeURIComponent(decodedValue) : '';
    } catch (error) {
        console.error('URL参数解析错误:', error);
        return name.endsWith('[]') ? [] : '';
    }
}